<?php
namespace app\index\model;
use think\Model;
// 需找赔率
class Rate extends model{
	function finds($andicap=1,$bet){
		// 对应目录的赔率
		$result = db("rate")->where(['andicap'=>$andicap,'bet'=>$bet])->select();
		return $result;
	}
	function findzm(){
		$res = db("rate")->where(["bet"=>1,"colums"=>1])->where('bets','>',57)->where('bets','<',62)->select();
		return $res;
	}
	function zhaorate($bet,$colums=1,$bets){
		$rate = cache("rate");
		if(!$rate)$rate=[];
		if(isset($rate[$bet][$colums][$bets])){
			return $rate[$bet][$colums][$bets];
		}
		$result = db("rate")->where(['bet'=>$bet,"colums"=>$colums,"bets"=>$bets])->field('id,ra,bets,name')->find();
		$rate[$bet][$colums][$bets] = $result;
		cache("rate",$rate);
		return $result;
	}
	function findrate62_63(){
		$res = db("rate")->where(["bet"=>1,"colums"=>1])->where('bets','>',61)->where('bets','<',65)->select();
		return $res;
	}
	function findes($andicap=1,$bet,$colums=1){
		// 对应目录的赔率
		$result = db("rate")->where(['andicap'=>$andicap,'bet'=>$bet,"colums"=>$colums])->field('id,ra,bets,restricts')->select();
		return $result;
	}
	function findrateA($andicap){
		$res = db("rate")->where(["andicap"=>$andicap,"bet"=>1,"colums"=>1])->field('id,ra,bet,bets,name')->select();
		// mp($res);
		return $res;
	}
	function findrateB(){
		$res = db("rate")->where(["bet"=>1,"colums"=>2])->field('id,ra,bets')->select();
		return $res;
	}
	function findrateX(){
		$res = db("rate")->where(["bet"=>1,"colums"=>1])->where('bets','>',49)->select();
		return $res;
	}
	function findrate($andicap,$bet,$colums,$bets){
		// 找到具体的赔率
		$res = db("rate")->where(["andicap"=>$andicap,"bet"=>$bet])->where(["colums"=>$colums,'bets'=>$bets])->find();
		return $res;
	}
}